package com.hllxd.hism.star.basic.service.model.smart;

import lombok.Data;

import java.util.ArrayList;
import java.util.List;

/**
 * @author lixiyong01
 * @date 2023.05.23
 * 树根节点
 */

@Data
public class TblSmartDqTreeLeaf {
    public String type="column";
    /** column*/
    public String text;

    public String columnId,columnName,columnNameCn,columnType,columnComment;

    public static List<TblSmartDqTreeLeaf> build(String columns) {

        List<TblSmartDqTreeLeaf> items = new ArrayList<>();
        String[] arr = columns.split(",");
        for(String column: arr) {
            String[] attrs = column.split("\\^");
            if(attrs.length != 4) {
                continue;
            }
            // 1^ent_name^企业名称^string
            TblSmartDqTreeLeaf leaf = new TblSmartDqTreeLeaf();
//                leaf.columnId = attrs[0];
            leaf.columnName = attrs[0];
            leaf.columnNameCn = attrs[1];
            leaf.columnType = attrs[2];
            leaf.columnComment = attrs[3];

            leaf.text = leaf.columnNameCn+"("+leaf.columnName+")  ["+leaf.columnType+"]";
            items.add(leaf);
        }
        return items;
    }
}
